﻿using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace Office365.SharePointOnline.Cmdlets
{
    public class SharePointOnlineService : Office365.SharePointOnline.Cmdlets.ISharePointOnlineService
    {
        public string Password { get; set; }
        public string Username { get; set; }

        public ICredentials Authenticate() {
            System.Security.SecureString password = new System.Security.SecureString();
            var pwdCharList = Password.ToCharArray();

            foreach (char ch in pwdCharList)
            {
                password.AppendChar(ch);
            }
            Microsoft.SharePoint.Client.SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(Username, password);
            return credentials;
        }
    }
}
